package com.zxbit.flash.network;

import com.alibaba.android.arouter.launcher.ARouter;
import com.zxbit.flash.base.BaseResponse;
import com.zxbit.flash.common.Constant;
import com.zxbit.flash.common.RouterMap;
import com.zxbit.flash.common.UserInfo;

import io.reactivex.functions.Consumer;

public abstract class CustomConsumer<T extends BaseResponse> implements Consumer<T> {


    @Override
    public void accept(T t) throws Exception {
        if (t.getStatus() == Constant.LOGIN_TIMEOUT) {
            ARouter.getInstance().build(RouterMap.FACEBOOKLOGIN).navigation();
            UserInfo.logout();
            return;
        }
        call(t);
    }


    public abstract void call(T t);
}
